/**
 * Created by Administrator on 2016/10/31 0031.
 */
/*简单的banner插件*/
function Banner(Img, Tab, Wrap) {
    this.img = Img;
    this.tab = Tab;
    this.wrap = Wrap;
    this.length = this.tab.length;
    this.index = 0;
    this.timer = null;
    this.init();

}
/*主要的效果原型*/
Banner.prototype.init = function () {
    this.img[0].className = 'on';
    this.tab[0].className = 'active';
    var This = this;
    for (var i = 0; i < this.length; i++) {
        this.tab[i].index = i;
        this.tab[i].onmouseenter = function () {
            var a = this;
            This.change(function () {
                This.index = a.index;
            });
        };
    };
    this.auto();
    this.wrap.onmouseenter = function () {
        clearInterval(This.timer);
    };
    this.wrap.onmouseleave = function () {
        This.auto();
    };
};
/*定时器系统的原型*/
Banner.prototype.auto = function () {
    var This = this;
    this.timer = setInterval(function () {
        This.change(function () {
            This.index++;
            This.index = This.index % This.length;
        });
    }, 3000);
}
;
/*切换效果的封装的原型*/
Banner.prototype.change = function change(fn) {
    this.tab[this.index].className = '';
    this.img[this.index].className = '';
    fn && fn();
    this.tab[this.index].className = 'active';
    this.img[this.index].className = 'on';
};


